import 'dart:ui';

import 'package:kq_flutter_core_widget/widgets/chart/radar/base/axis.dart';

import '../../base/base_chart.dart';

/// 雷达图基类
abstract class BaseRadarChartDelegate<D> extends BaseChartDelegate<D> {
  BaseRadarChartDelegate(
      {required this.radius,
      this.drawStartAngle = 0,
      required this.xAxisRender,
      required this.yAxisRender,
      required this.dataRender,
      required this.xAxis,
      required this.yAxis,
      super.data,
      super.animDuration,
      super.emptyWidgetBuilder,
      super.gestureHandler,
      super.isDataEmpty});

  /// 饼状图半径
  final double radius;

  /// 起始绘制的角度
  final double drawStartAngle;

  final BaseRadarAxisRender xAxisRender;
  final BaseRadarAxisRender yAxisRender;
  final BaseRadarDataRender dataRender;
  final RadarAxis xAxis;
  final RadarAxis yAxis;

  @override
  void onDraw(Canvas canvas, double animProgress) {
    if (radius < 0) {
      return;
    }

    xAxisRender.onDraw(this, canvas);
    yAxisRender.onDraw(this, canvas);
    dataRender.onDraw(this, canvas, animProgress);
  }
}

/// 雷达图轴绘制器
mixin BaseRadarAxisRender<C extends BaseRadarChartDelegate> {
  void onDraw(C chart, Canvas canvas);
}

/// 雷达图内容绘制器
mixin BaseRadarDataRender<C extends BaseRadarChartDelegate> {
  void onDraw(C chart, Canvas canvas, double animProgress);
}
